<template>
	<view class="index-box">
		<!-- <view class="content">
			<leaveList></leaveList>
		</view> -->
		<view v-if="leaveList.length==0" style="text-align: center;">
			<image src="../../../static/nodata.png" class="nodata_img" ></image>
		</view>
		<view class="leave-box" v-if="leaveList.length>0">
			<!-- <loadMore :onLoadMore="onLoadMore" :loadMore="loadMore"> -->
			<view class="leave-content" @click="DetailsBtn(item.leave_id)" v-for="(item,index) in leaveList" :key="index">
				<view class="leave-content-left">
					<view class="leave-content-left-top" v-if="item">
						<view class="leave-content-name" v-if="item">{{item.name}}</view>
						<view class="leave-content-classnumber" v-if="item">学号：{{item.sno}}</view>
					</view>
					<view class="leave-content-time">
						<view class="leave-tiem" v-if="item">请假时间：（总时长{{item.hours}}小时）</view>
						<view class="leave-date" v-if="item">{{item.begintime?item.begintime.substring(0,16):''}} 至 
																								 {{item.endtime?item.endtime.substring(0,16):''}}</view>
					</view>
				</view>
				<view class="leave-content-right">
					<!-- <view class="leave-content-right-box">请假申请</view> -->
					<button class="button_status" style="color: #77312A;">请假申请</button>
				</view>
			</view>
			<!-- </loadMore> -->
		</view>
	</view>
</template>

<script>
	// import leaveList from '@/pages/components/leaveList.vue'
		import loadMore from "@/pages/components/loadmore.vue"
	export default {
		data() {
			return {
				name: '李四',
				id: '0000000001',
				//首页信息列表
				leaveList: [],
				isShow: false,
				//分页
				page: 1,
				loadMore: true,
			}
		},
		methods: {
			DetailsBtn(id) {
					console.log('11111')
					console.log(id)
					uni.navigateTo({
						url: '/pages/leaveinfo/leaveinfo?id=' + id
					});
			
				},
				onLoadMore(done) {
					setTimeout(() => {
						if (!this.enableLoadMore) {
							return
						}
						this.page = this.page + 1
						this.getData();
						done();
					}, 200)
				},
			
				getData() {
					// 请求接口 ↓↓↓
					//请求首页数据
					uni.request({
						// url: "/api/appteacher/searchIndexDataOfTeacher",
						url: this.baseUrl+ "/appteacher/searchIndexDataOfTeacher?satoken="+uni.getStorageSync('satoken'),
						method: "POST",
						headers: {
							// "token": localStorage.getItem("token")
						},
						data: {
							page: this.page,
							length: '50'
						},
						success: (res) => {
							console.log(res)
							this.leaveList = res.data.page.list
						}
					})
				}
			
			
		},
		mounted() {
			this.getData()
		},
		components: {
			loadMore
		},

	}
</script>

<style lang="scss">
		@import url('../../../static/common.css');
	.index-box {
		width: 95%;
		margin: 0 auto;
	}
</style>
